export default {
	check(isOk, msg) {
	  if (!isOk) {
	    this.warn(msg)
	    return false
	  }
	  return true
	},
	info(title, {
		duration = 3000,
		icon = 'none'
	} = {}) {
		uni.showToast({
			title,
			icon,
			duration
		})
	},
	warn(title) {
		this.info(title)
	},
	success(title) {
		this.info(title)
	},
	error(title) {
		this.info(title)
	},
	confirm(title, {
		content = {},
		confirmText = '确定',
		cancelText = '取消'

	}) {
		return new Promise((resolve, reject) => {
			uni.showModal({
				title,
				content,
				confirmText,
				cancelText,
				success(res) {
					if (res.confirm) {
						resolve()
					} else {
						reject()
					}
				}
			})
		})
	},
	showLoading(title, mask = false) {
		uni.showLoading({
			title: '处理中，请稍候',
			mask
		})
	},
	hideLoading() {
		uni.hideLoading()
	}
}